package 强化训练;

import java.util.*;

public class day43电话号码  {
    public static void main(String[] args) {
        //将英文对应的字母全部转换为数字
        Hashtable<Character, Integer> table = createTable();
        //处理数据
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            TreeSet<String> queue = new TreeSet<>();
            StringBuilder sb = new StringBuilder();
            int n = sc.nextInt();
            sc.nextLine();
            for (int j = 0; j < n; j++) {
                String s = sc.next();
                char[] chars = s.toCharArray();
                for (int i = 0; i < chars.length; i++) {
                    if (chars[i] - '0' >= 0 && chars[i] - '9' <= 0){
                        sb.append(chars[i]);
                    }else if (chars[i] == '-'){
                        continue;
                    }else {
                        sb.append(table.get(chars[i]));
                    }
                }
                sb.insert(3,"-");
                //字符串转换完成
                queue.add(sb.toString());

                sb.delete(0,sb.length());
            }
            queue.forEach((str)-> System.out.println(str.toString()));
            System.out.println();
        }

    }

    private static Hashtable<Character, Integer> createTable(){
        Hashtable<Character,Integer> table = new Hashtable<>();
        int count = 2;
        for (int i = 0; i < 26; i++) {
            table.put((char)('A'+i),count);
            if (count == 7  || count == 9){
                int co = 0;
                while (co < 4){
                    table.put((char)('A'+i),count);
                    i++;
                    co++;
                }
                i--;
                count++;
            }else {
                if (count == 8){
                    int co = 0;
                    while (co < 3){
                        table.put((char)('A'+i),count);
                        i++;
                        co++;
                    }
                    count++;
                    i--;
                } else if ((i + 1) % 3 == 0){
                    count++;
                }
            }
        }
        return table;
    }
}
